00001
00002
00003
00004
00005
00006 #ifndef _data_collection_h
00007 #define _data_collection_h
00008
00009 #define OLD_MAP
00010
00011 #ifndef OLD_MAP
00012 #include <boost/unordered_map.hpp>
00013 #endif
00014 #include <map>
00015 #include <string>
00016 #include <boost/serialization/map.hpp>
00017 #include <boost/serialization/string.hpp>
00018
00019 #include "gridpack/utilities/complex.hpp"
00020
00021 #include <boost/serialization/export.hpp>
00022
00023
00024
00025 namespace gridpack{
00026 namespace component{
00027
00028 class DataCollection {
00029 public:
00030
00031
00032
00033 DataCollection(void);
00034
00035
00036
00037
00038 ~DataCollection(void);
00039
00040
00041
00042
00043 DataCollection & operator= (const DataCollection &rhs);
00044
00045
00046
00047
00048
00049
00050 void addValue(const char *name, const int value);
00051 void addValue(const char *name, const long value);
00052 void addValue(const char *name, const bool value);
00053 void addValue(const char *name, const char *value);
00054 void addValue(const char *name, const float value);
00055 void addValue(const char *name, const double value);
00056 void addValue(const char *name, const gridpack::ComplexType value);
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 void addValue(const char *name, const int value, const int idx);
00067 void addValue(const char *name, const long value, const int idx);
00068 void addValue(const char *name, const bool value, const int idx);
00069 void addValue(const char *name, const char *value, const int idx);
00070 void addValue(const char *name, const float value, const int idx);
00071 void addValue(const char *name, const double value, const int idx);
00072 void addValue(const char *name, const gridpack::ComplexType value, const int idx);
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 bool setValue(const char *name, const int value);
00083 bool setValue(const char *name, const long value);
00084 bool setValue(const char *name, const bool value);
00085 bool setValue(const char *name, const char *value);
00086 bool setValue(const char *name, const float value);
00087 bool setValue(const char *name, const double value);
00088 bool setValue(const char *name, const gridpack::ComplexType value);
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 bool setValue(const char *name, const int value, const int idx);
00101 bool setValue(const char *name, const long value, const int idx);
00102 bool setValue(const char *name, const bool value, const int idx);
00103 bool setValue(const char *name, const char *value, const int idx);
00104 bool setValue(const char *name, const float value, const int idx);
00105 bool setValue(const char *name, const double value, const int idx);
00106 bool setValue(const char *name, const gridpack::ComplexType value, const int idx);
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116 bool getValue(const char *name, int *value);
00117 bool getValue(const char *name, long *value);
00118 bool getValue(const char *name, bool *value);
00119 bool getValue(const char *name, std::string *value);
00120 bool getValue(const char *name, float *value);
00121 bool getValue(const char *name, double *value);
00122 bool getValue(const char *name, gridpack::ComplexType *value);
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 bool getValue(const char *name, int *value, const int idx);
00135 bool getValue(const char *name, long *value, const int idx);
00136 bool getValue(const char *name, bool *value, const int idx);
00137 bool getValue(const char *name, std::string *value, const int idx);
00138 bool getValue(const char *name, float *value, const int idx);
00139 bool getValue(const char *name, double *value, const int idx);
00140 bool getValue(const char *name, gridpack::ComplexType *value, const int idx);
00141
00142
00143
00144
00145 void dump(void);
00146 private:
00147 #ifdef OLD_MAP
00148 std::map<std::string, int> p_ints;
00149 std::map<std::string, long> p_longs;
00150 std::map<std::string, bool> p_bools;
00151 std::map<std::string, std::string> p_strings;
00152 std::map<std::string, float> p_floats;
00153 std::map<std::string, double> p_doubles;
00154 std::map<std::string, gridpack::ComplexType> p_complexType;
00155 #else
00156 boost::unordered_map<std::string, int> p_ints;
00157 boost::unordered_map<std::string, long> p_longs;
00158 boost::unordered_map<std::string, bool> p_bools;
00159 boost::unordered_map<std::string, std::string> p_strings;
00160 boost::unordered_map<std::string, float> p_floats;
00161 boost::unordered_map<std::string, double> p_doubles;
00162 boost::unordered_map<std::string, gridpack::ComplexType> p_complexType;
00163 #endif
00164
00165 private:
00166 friend class boost::serialization::access;
00167
00168
00169 template<class Archive> void serialize(Archive &ar, const unsigned int)
00170 {
00171 ar & p_ints
00172 & p_longs
00173 & p_bools
00174 & p_strings
00175 & p_floats
00176 & p_doubles
00177 & p_complexType;
00178 }
00179
00180 };
00181
00182
00183 }
00184 }
00185
00186 BOOST_CLASS_EXPORT_KEY(gridpack::component::DataCollection)
00187
00188 #endif // _data_collection_h